public class SplitStat implements Stat {
  private float weightL, weightR, meanL, meanR;
  int thresh;

  public SplitStat(int t) {
    this.thresh = t;
  }

  public float getWeightL() {
    return this.weightL;
  }
  
  public float getWeightR() {
    return this.weightR;
  }
  
  public float getMeanL() {
    return this.meanL;
  }
  
  public float getMeanR() {
    return this.meanR;
  }
  
  public int getThresh() {
    return this.thresh;
  }
  
  public void setThresh(int t) {
    this.thresh = t;
  }
  
  public void process(float[] ps) {
    weightL = 0;      
    weightR = 0;
    float sumL = 0;
    float sumR = 0;
    for (int i = 0; i < thresh; i++) {
      weightL += ps[i]; 
      sumL += i * ps[i];
    }
    for (int i = thresh; i < ps.length; i++) {
      weightR += ps[i]; 
      sumR += i * ps[i];
    }
    meanL = sumL / weightL;
    meanR = sumR / weightR;
  }
}
